<?php if(isset($user)): ?>
<?php if(isset($blueBarOffers) && !empty($blueBarOffers)): ?>

<script type="text/javascript">
	(function($){
	    $.fn.autoscroll = function(options){
	        var opts = $.extend({},
	        					{	speed: 1000,	// if <= 0, stop auto scroll
									prebtn: {},
									nextbtn: {},
									pagePannel: {}
	        					},
	        					options);
			var t;
			var totalCount;
	        
	        var autoScrollFun = function(element, orient){
				if(!element.children('.curr').size()){
					element.children().hide();
					element.children().first().show().addClass('curr');
				}else{
			        if(orient){  //right
				        var nextline = element.children('.curr').next();
				        if(!nextline.html()){
							nextline = element.children().first();
				        }
			        }else{		//left
						var nextline = element.children('.curr').prev();
						if(!nextline.html()){
							nextline = element.children().last();
				        }
			        }
			        element.children('.curr').hide().removeClass('curr');
			        nextline.addClass('curr').show();
				}

		        var currIndex = element.children('.curr').index() + 1;
		        opts.pagePannel.html(currIndex+'/'+totalCount);
		        if(opts.speed > 0){
			        clearTimeout(t);
			        t = setTimeout(function(){autoScrollFun(element, 1);}, opts.speed);
		        }
	        };
			
	        return $(this).each(function(){
	        	var element = $(this);
	        	totalCount = element.children().size();
	        
				opts.nextbtn.click(function(){
					autoScrollFun(element, 1);
				});
	
				opts.prebtn.click(function(){
					autoScrollFun(element, 0);
				});
	        	autoScrollFun(element, 1);
	        });
	    };
	})(jQuery);		
</script>

<style>
<!--
	.offer_bar{
		top:0; 
		left:0;
		width:100%; 
		height:30px;
		background-color:#56A8F5;
	}
	
	.offer_bar_inbox{
		height:30px;
		width:1060px;
		margin:0 auto;
	}
	
	.message_box{
		width:800px;
		height:30px;
		line-height:30px;
		color:#003366;
		text-align:left;
		float:left;
	}
	.message_box a{
		font-weight:bold;
		color:#FFF;
		text-decoration:underline;
	}
	
	.page_box{
		width:260px;
		height:30px;
		line-height:30px;
		float:left;
	}
	.page_box .pagePann{
		font-weight:bold;
		float:left;
		width:60px;
		color:#003366;
	}
	.page_box a{
		font-weight:bold;
		cursor:pointer;
		float:left;
		width:20px;
		height:20px;
		line-height:20px;
		border: solid 1px #89C5FF;
		margin-top:5px;
		margin-left:2px;
		color:#1F72C2;
		text-align:center;
	}
-->
</style>





<div class="offer_bar" style="position:fixed; z-index:100;">
	<div class="offer_bar_inbox">
		<div class="message_box">
			<?php foreach($blueBarOffers as $blueBarOffer): ?>
			<div>
				<a href="<?php echo url('default/bluebarofferclick', array('bluebarofferid' => $blueBarOffer['id']));?>" target="_blank">Get <?php echo $blueBarOffer['credit']; ?> <?php echo ($blueBarOffer['is_partial'] == '1')? 'Partial' : ''; ?> Credits!</a>
				<?php echo $blueBarOffer['offer_text']; ?>
			</div>
			<?php endforeach; ?>
		</div>
		
		<div class="page_box">
			<div class="pagePann"></div>
			<a class="prebtn"><</a>
			<a class="nextbtn">></a>
		</div>
	</div>
</div>
<div class="offer_bar"></div>

<script type="text/javascript">
	$('.message_box').autoscroll({
		speed: 0,
		prebtn: $('.prebtn'),
		nextbtn: $('.nextbtn'),
		pagePannel: $('.pagePann')		
	});
</script>


<?php endif; ?>
<?php endif; ?>
